#!/usr/bin/python2.7

class Vector2:
  def __init__(self, x, y):
    self.x, self.y = float(x),float(y)
  def __add__(self, vector):
    if isinstance(vector,Vector2):
       return Vector2(self.x+vector.x,self.y+vector.y)
  def __sub__(self, vector):
    if isinstance(vector,Vector2):
       return Vector2(self.x-vector.x,self.y-vector.y)
  def __mul__(self, vector):
    if isinstance(vector,Vector2):
       return self.x*vector.x + self.y*vector.y
  def __str__(self):
    return "(%.2f,%.2f)" % (self.x, self.y)
  def __call__(self):
    print("(%.2f,%.2f)" % (self.x, self.y))
  def __eq__(self, vector):
    if isinstance(vector,Vector2):
       if vector.x == self.x and vector.y == self.y: return True
       else: return False

#Sledeci if ispituje da li smo python skriptu pokrenuli
#kao izvrsni fajl. U tom slucaju je __name__ promenljiva
#koju koristi interpreter setovana na __main__
if __name__ == "__main__":
  a = Vector2(1,2)
  b = Vector2(1,4)

  print(a+b)

  assert a+b == Vector2(2,6), "There is an error in vector addition"
  assert a-b == Vector2(0,-2), "There is an error in vector substraction"
  assert a*b == 9 , "There is an error in vector scalar multiplication"
